#include "StdAfx.h"
#include "MainView.h"
#include "ControlEx/UIConfig.h"
#include "ControlEx/CtrlBuilder.h"
#include "LoginDlg.h"
#include "PiaoSettingDlg.h"
#include "Util.h"
#include "common.h"


CMainView::CMainView(void)
	//: m_pViewContainer(NULL)
{
}


CMainView::~CMainView(void)
{
}
//
//void CMainView::CreateWnd(HWND parentWnd, const RECT & rect, LPCTSTR  strText, const Color & textColor)
//{
//	CControlUI::CreateWnd(parentWnd, rect, strText, textColor);
//	GetViewContainner(strText);
//}
//
//CViewContainer *  CMainView::GetViewContainner(const wstring & strViewName)
//{
//	if (!m_pViewContainer)
//	{
//		CCtrlBuilder * pBuilder = this->GetBuilder();
//		CUIConfig *pUIconfig = CUIConfig::GetUIConfigInstance();
//		m_pViewContainer = pUIconfig->GetViewContainByName(strViewName);
//	    m_pViewContainer->CreateView(this);
//		ASSERT(m_pViewContainer);
//	}
//
//	return m_pViewContainer;
//}

void CMainView::InitFormView()
{
	GetBuilder()->RegisterBtnClicked(&CMainView::onClickLogin12306, this, GetCtrlByName("btnLogin12306"));
	GetBuilder()->RegisterBtnClicked(&CMainView::onClickQA, this, GetCtrlByName("btnQA"));
	GetBuilder()->RegisterBtnClicked(&CMainView::onClickGenQRImage, this, GetCtrlByName("btnTBarGen"));
	GetBuilder()->RegisterBtnClicked(&CMainView::onClickAddCenterImage, this, GetCtrlByName("btnTBarImage"));

	GetBuilder()->RegisterBtnClicked(&CMainView::onClickCancel, this, GetCtrlByName("btnClose"));
}

void CMainView::onClickLogin12306()
{
	CLoginDlg dlg;
	dlg.DoModal(m_parentWnd);
	//CFileDialog dlg(TRUE, NULL, NULL, OFN_NONETWORKBUTTON|OFN_FILEMUSTEXIST, _T("Image Files|*.jpg;*.png;*.gif;*.bmp||All Files(*.*)|*.*||"));
	//if (dlg.DoModal(m_parentWnd) == IDOK)
	//{
	//	//TCHAR szFile[MAX_PATH];
	//	dlg.m_szFileName;//(szFile, MAX_PATH);
	//}
}

void CMainView::onClickGenQRImage()
{
	CPiaoSettingDlg view;
	if (view.DoModal(m_parentWnd) == IDOK)
	{
	}
}

void CMainView::onClickAddCenterImage()
{
}

void CMainView::onClickQA()
{
	OpenUrl(STRING_URL_QA);
}

void CMainView::onClickCancel()
{
	//EndDialog(m_parentWnd, IDCANCEL);
	DestroyWindow(m_parentWnd);
	::PostQuitMessage(IDCANCEL);
}
